# include <bits/stdc++.h>
# define MAXN 100023
# define mid ((l + r) >> 1)
using namespace std;

inline int gn() {
	int k = 0, f = 1;
	char c = getchar();
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) k = k * 10 + c - '0';
	return k * f;
}

struct node {
	int sum;
	node *ls, *rs;
	node() {
		sum = 0;
		ls = rs = NULL;
	}
}*root[MAXN];

node *build(int l, int r) {
	node *x = new node();
	if(l ^ r) {
		x->ls = build(l, mid);
		x->rs = build(mid + 1, r);
	}
	return x;
}

node *add(node *pre, int l, int r, int k) {
	node *x = new node();
	if(l ^ r) {
		if(k <= mid) {
			x->ls = add(pre->ls, l, mid, k);
			x->rs = pre->rs;
		} else {
			x->ls = pre->ls;
			x->rs = add(pre->rs, mid + 1, r, k);
		}
		x->sum = x->ls->sum + x->rs->sum;
	} else x->sum = pre->sum + 1;
	return x;
}

inline int query(node *s, node *t, int l, int r, int k) {
	if(l ^ r) {
		if(k <= t->ls->sum - s->ls->sum) return query(s->ls, t->ls, l, mid, k);
		else return query(s->rs, t->rs, mid + 1, r, k - (t->ls->sum - s->ls->sum));
	} else return l;
}

int n, m, a[MAXN], maxa = -0x7fffffff, mina = 0x7fffffff;

int main() {
	//freopen("in.txt", "r", stdin);
	//freopen("kthnumber.in", "r", stdin);
	//freopen("kthnumber.out", "w", stdout);
	n = gn();
	m = gn();
	for(int i = 1;  i <= n; i++) {
		maxa = max(maxa, a[i] = gn());
		mina = min(mina, a[i]);
	}
	root[0] = build(mina, maxa);
	for(int i = 1; i <= n; i++) {
		root[i] = add(root[i - 1], mina, maxa, a[i]);
	}
	int s, t, k;
	while(m--) {
		s = gn();
		t = gn();
		k = gn();
		printf("%d\n", query(root[s - 1], root[t], mina, maxa, k));
	}
}
